package open.witype.filetiper.fragment.file.db;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import open.witype.filetiper.database.BaseDBAdapter;
import open.witype.filetiper.database.DBHelper;
import open.witype.filetiper.model.RemarkEntity;

/**
 * Created by Typer on 2015/5/29 0029.
 */
public class RemarkDBAdapter extends BaseDBAdapter {

    public RemarkDBAdapter(Context context) {
        super(context);
    }

    public RemarkEntity getRemarks(String path) {
        if (database == null)
            return new RemarkEntity();
        Cursor cur = database.query(true, DBHelper.REMARK_TABLE,null,"path=?",new String[]{path},null,null,null,null);
        if (cur == null)
            return new RemarkEntity();
        if (cur.getCount() == 0)
            return new RemarkEntity();
        RemarkEntity model = new RemarkEntity();
        cur.moveToFirst();
        model.setId(cur.getString(0));
        model.setPath(cur.getString(1));
        model.setRemark(cur.getString(2));
        model.setVersion(cur.getString(3));
        cur.close();
        return model;
    }
}
